package com.mirror.utils.view;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CustomViewPager extends ViewPager {

	private boolean isDisallowIntecept = true;

	public boolean isDisallowIntecept() {
		return isDisallowIntecept;
	}

	public void setDisallowIntecept(boolean isDisallowIntecept) {
		this.isDisallowIntecept = isDisallowIntecept;
	}

	public CustomViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public CustomViewPager(Context context) {
		super(context);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		boolean ret = super.dispatchTouchEvent(ev);
		if (ret && isDisallowIntecept) {
			requestDisallowInterceptTouchEvent(true);
		}
		return ret;
	}
}
